package com.cxx.home.config;

import com.cxx.home.constant.FileConstant;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: Cxx
 * @Date: 2024/9/22 10:57
 * @Description:
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Value("${file.path}")
    private String filePath;

    @Value("${file.log-path}")
    private String logFilePath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/" + FileConstant.FILE_URL_PREFIX + "/**")
                .addResourceLocations("file:" + filePath);

        registry.addResourceHandler("/" + FileConstant.FILE_LOG_PREFIX + "/**")
                .addResourceLocations("file:" + logFilePath);
    }
}

